/**
 * @file LogAppender.h
 * @author  haifeng (haifengxiao@icloud.com)
 * @brief
 * @version 0.1
 * @date 2021-07-06
 *
 * @copyright Copyright (c) 2021
 *
 */

#pragma once

#include <memory>
#include "LogFormatter.h"
#include "Logger.h"
#include "LogEvent.h"

namespace Chen {
    namespace Log {

        class LogAppender {

            friend class Logger;
        public:
            typedef std::shared_ptr<LogAppender> ptr;

            /**
             * @brief Destroy the Log Appender object
             *
             */
            virtual ~LogAppender() {}

            /**
             * @brief Write  log
             *
             * @param logger logger
             * @param level log level
             * @param event log event
             */
            virtual void log(std::shared_ptr<Logger> logger
                , LogLevel::Level level, LogEvent::ptr event) = 0;

            /**
             * @brief Set the Level object
             *
             * @param val log level
             */
            void setLevel(LogLevel::Level val) { m_level = val; }

            /**
             * @brief Get the Level object
             *
             * @return LogLevel::Level
             */
            LogLevel::Level getLevel() { return m_level; }

            /**
             * @brief Set the Formatter object
             *
             * @param val log formatter
             */
             //void setFormatter(LogFormatter::ptr val);

             /**
              * @brief Get the Formatter object
              *
              * @return LogFormatter::ptr
              */
              //LogFormatter::ptr getFormatter();

        protected:
            /// the default log level
            LogLevel::Level m_level = LogLevel::DEBUG_;
            /// if the log target has formatter
            bool m_hasFormatter = false;
            /// log formatter
            LogFormatter::ptr m_formatter;
        };

    }//namespace Log
}//namespace Chen